﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AhCha.Fortunate.Common.Utility
{
    public delegate string PublicTestAction();
    public class TestConfigs
    {
        private Dictionary<string, PublicTestAction> actions;
        public TestConfigs()
        {
            actions = new Dictionary<string, PublicTestAction>()
            {
                { "111",Test1},
                { "222",Test2},
            };
        }

        private string Test1()
        {
            Console.WriteLine("Test1");
            return "Test1";
        }
        private string Test2()
        {
            Console.WriteLine("Test2");
            return "Test2";
        }

        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="key">Key</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task<string> ExecuteAction(string key)
        {
            if (actions.TryGetValue(key, out PublicTestAction action))
            {
               return action();
            }
            else
            {
                return "请稍后重试";
            }
        }

    }

}
